.class Lcom/opongo/blogapp/activities/PostViewActivity$1;
.super Landroid/webkit/WebViewClient;
.source "PostViewActivity.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/opongo/blogapp/activities/PostViewActivity;->onCreate(Landroid/os/Bundle;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation


# instance fields
.field final synthetic this$0:Lcom/opongo/blogapp/activities/PostViewActivity;


# direct methods
.method constructor <init>(Lcom/opongo/blogapp/activities/PostViewActivity;)V
    .locals 0
    .parameter

    .prologue
    .line 1
    iput-object p1, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    .line 73
    invoke-direct {p0}, Landroid/webkit/WebViewClient;-><init>()V

    return-void
.end method


# virtual methods
.method public onPageFinished(Landroid/webkit/WebView;Ljava/lang/String;)V
    .locals 4
    .parameter "view"
    .parameter "url"

    .prologue
    .line 112
    iget-object v2, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    #getter for: Lcom/opongo/blogapp/activities/PostViewActivity;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;
    invoke-static {v2}, Lcom/opongo/blogapp/activities/PostViewActivity;->access$0(Lcom/opongo/blogapp/activities/PostViewActivity;)Lcom/opongo/blogapp/manager/DatabaseManager;

    move-result-object v2

    if-eqz v2, :cond_0

    .line 113
    iget-object v2, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    #getter for: Lcom/opongo/blogapp/activities/PostViewActivity;->dbManager:Lcom/opongo/blogapp/manager/DatabaseManager;
    invoke-static {v2}, Lcom/opongo/blogapp/activities/PostViewActivity;->access$0(Lcom/opongo/blogapp/activities/PostViewActivity;)Lcom/opongo/blogapp/manager/DatabaseManager;

    move-result-object v2

    iget-object v3, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    #getter for: Lcom/opongo/blogapp/activities/PostViewActivity;->post:Lcom/opongo/blogapp/common/Post;
    invoke-static {v3}, Lcom/opongo/blogapp/activities/PostViewActivity;->access$1(Lcom/opongo/blogapp/activities/PostViewActivity;)Lcom/opongo/blogapp/common/Post;

    move-result-object v3

    iget v3, v3, Lcom/opongo/blogapp/common/Post;->id:I

    invoke-virtual {v2, v3}, Lcom/opongo/blogapp/manager/DatabaseManager;->queryForCommentCountByPostId(I)I

    move-result v0

    .line 114
    .local v0, commentcount:I
    const-string v1, "0 Kommentare"

    .line 115
    .local v1, commentcountText:Ljava/lang/String;
    const/4 v2, 0x1

    if-ne v0, v2, :cond_1

    .line 116
    const-string v1, "1 Kommentar"

    .line 120
    :goto_0
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "javascript:{var comment = document.getElementById(\'comments_box\'); if(comment != null)comment.innerText = \'"

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "\';};"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {p1, v2}, Landroid/webkit/WebView;->loadUrl(Ljava/lang/String;)V

    .line 122
    .end local v0           #commentcount:I
    .end local v1           #commentcountText:Ljava/lang/String;
    :cond_0
    return-void

    .line 118
    .restart local v0       #commentcount:I
    .restart local v1       #commentcountText:Ljava/lang/String;
    :cond_1
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v0}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, " Kommentare"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    goto :goto_0
.end method

.method public shouldOverrideUrlLoading(Landroid/webkit/WebView;Ljava/lang/String;)Z
    .locals 10
    .parameter "view"
    .parameter "url"

    .prologue
    const/4 v9, 0x0

    const/4 v8, 0x1

    .line 76
    const-string v5, "show:"

    invoke-virtual {p2, v5}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_0

    .line 77
    iget-object v5, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    invoke-virtual {v5}, Lcom/opongo/blogapp/activities/PostViewActivity;->showComments()V

    .line 105
    :goto_0
    return v8

    .line 79
    :cond_0
    const-string v5, "vote:"

    invoke-virtual {p2, v5}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_2

    .line 80
    iget-object v5, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    invoke-virtual {v5}, Lcom/opongo/blogapp/activities/PostViewActivity;->getApplicationContext()Landroid/content/Context;

    move-result-object v5

    .line 81
    iget-object v6, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    const v7, 0x7f070048

    invoke-virtual {v6, v7}, Lcom/opongo/blogapp/activities/PostViewActivity;->getString(I)Ljava/lang/String;

    move-result-object v6

    .line 80
    invoke-static {v5, v6, v9}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

    move-result-object v4

    .line 82
    .local v4, toast:Landroid/widget/Toast;
    invoke-virtual {v4}, Landroid/widget/Toast;->show()V

    .line 86
    :try_start_0
    new-instance v2, Ljava/net/URI;

    invoke-direct {v2, p2}, Ljava/net/URI;-><init>(Ljava/lang/String;)V

    .line 87
    .local v2, link:Ljava/net/URI;
    invoke-virtual {v2}, Ljava/net/URI;->getPort()I

    move-result v3

    .line 88
    .local v3, post_id:I
    invoke-virtual {v2}, Ljava/net/URI;->getHost()Ljava/lang/String;

    move-result-object v5

    const-string v6, "hot"

    invoke-virtual {v5, v6}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-eqz v5, :cond_1

    .line 89
    const/4 v5, 0x1

    iget-object v6, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    invoke-virtual {v6}, Lcom/opongo/blogapp/activities/PostViewActivity;->getApplicationContext()Landroid/content/Context;

    move-result-object v6

    invoke-static {v3, v5, v6}, Lcom/opongo/blogapp/manager/APIManager;->voteSpicy(IZLandroid/content/Context;)Z
    :try_end_0
    .catch Ljava/net/URISyntaxException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    .line 93
    .end local v2           #link:Ljava/net/URI;
    .end local v3           #post_id:I
    :catch_0
    move-exception v0

    .line 95
    .local v0, e:Ljava/net/URISyntaxException;
    invoke-virtual {v0}, Ljava/net/URISyntaxException;->printStackTrace()V

    goto :goto_0

    .line 91
    .end local v0           #e:Ljava/net/URISyntaxException;
    .restart local v2       #link:Ljava/net/URI;
    .restart local v3       #post_id:I
    :cond_1
    const/4 v5, 0x0

    :try_start_1
    iget-object v6, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    invoke-virtual {v6}, Lcom/opongo/blogapp/activities/PostViewActivity;->getApplicationContext()Landroid/content/Context;

    move-result-object v6

    invoke-static {v3, v5, v6}, Lcom/opongo/blogapp/manager/APIManager;->voteSpicy(IZLandroid/content/Context;)Z
    :try_end_1
    .catch Ljava/net/URISyntaxException; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_0

    .line 101
    .end local v2           #link:Ljava/net/URI;
    .end local v3           #post_id:I
    .end local v4           #toast:Landroid/widget/Toast;
    :cond_2
    new-instance v1, Landroid/content/Intent;

    const-string v5, "android.intent.action.VIEW"

    invoke-direct {v1, v5}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 102
    .local v1, i:Landroid/content/Intent;
    invoke-static {p2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v5

    invoke-virtual {v1, v5}, Landroid/content/Intent;->setData(Landroid/net/Uri;)Landroid/content/Intent;

    .line 103
    iget-object v5, p0, Lcom/opongo/blogapp/activities/PostViewActivity$1;->this$0:Lcom/opongo/blogapp/activities/PostViewActivity;

    invoke-virtual {v5, v1}, Lcom/opongo/blogapp/activities/PostViewActivity;->startActivity(Landroid/content/Intent;)V

    goto :goto_0
.end method
